export default function detailCanvas(that,sWidth,sHeight,headimgUrl,imgUrl,codeImg,title,action,content,callback){
  let rpx = sWidth;
  const cxt = wx.createCanvasContext('myCanvas',that);
  cxt.save();
  cxt.setFillStyle('#fff')
  cxt.fillRect(0, 0, sWidth*375, sHeight-100);
      console.log('头像:'+headimgUrl)
      console.log('商品:'+imgUrl)
      console.log('二维码:'+codeImg)
     var avatorWidth = sWidth *50,avatorHeight = sWidth * 50;
     var avatarurlX =sWidth*375/2-50; 
     var avatarurlY =5;
     cxt.save();
     cxt.beginPath();
     cxt.arc(avatorWidth / 2 + avatarurlX, avatorHeight / 2 + avatarurlY, avatorWidth / 2, 0, Math.PI * 2, false);
     cxt.clip();
     cxt.drawImage(headimgUrl,sWidth*375/2-50,5, avatorWidth, avatorWidth);
     cxt.restore();
  


  //商品图片
  let detailImgHeight = (sWidth*375)*12/16;
  cxt.drawImage(imgUrl,15,10+sWidth*50,sWidth*375-sWidth*90,detailImgHeight);
  //二维码
  cxt.drawImage(codeImg,(sWidth*375-155*rpx),370*rpx,75*rpx,75*rpx);
  cxt.restore();
  //标题
  cxt.setFontSize(14);
  cxt.setFillStyle('#333333');
  if(title.length>14){
      cxt.fillText(title.slice(0,14),10*rpx,375*rpx);
      if(title.length>28)
      {
        cxt.fillText(title.slice(14,title.length)+'...',10*rpx,395*rpx);
      }
      else
      {
        cxt.fillText(title.slice(14,title.length),10*rpx,395*rpx);
      }
  }
  else
  {
    cxt.fillText(title,10*rpx,375*rpx);
  }
  

  cxt.setFillStyle('#999999');
  cxt.setFontSize('12');
  cxt.fillText('发现了一个好东西，第一时',10*rpx,420*rpx);
  cxt.fillText(action|| '间想跟你分享~',10*rpx,440*rpx);
  cxt.draw(false,()=>{
      wx.canvasToTempFilePath({
          x: 0,
          y: 0,
          canvasId:"myCanvas",
          fileType: 'png',
          success: (res)=>{
              callback(res.tempFilePath)
          },
         
      }, that);
  });
}